package com.zj.web.controller;

import com.zj.service.OrderdetailService;
import com.zj.web.bean.OrderdetailDTO;
import com.zj.web.bean.ResponseResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/auth/orderdetail")
@Tag(name = "订单详情管理",description = "实现对订单详情的增删改查工作")
public class OrderdetailController {
    @Autowired
    private OrderdetailService orderService;
    //添加订单详情
    @PostMapping("/add/{orderId}/details")
    public ResponseEntity<ResponseResult> addDetails(
            @PathVariable("orderId") Long orderId,
            @RequestBody List<OrderdetailDTO> detailList) {
        boolean success = orderService.addOrderDetail(orderId, detailList);
        return ResponseEntity.ok(ResponseResult.builder().code(1).msg("添加成功").data(success).build());
    }

}
